﻿using System;
using System.Collections.Generic;
using MyDMS.DAL;
using System.Linq;

public partial class DocumentTypes : PageBaseClass
{
    MyDMSEntity myDmsEntity =new MyDMSEntity();
    protected void Page_Load(object sender, EventArgs e)
    {
        List<DocumentType> dTypes = myDmsEntity.DocumentType.Where(r => r.Office_Code == Author.office_Code).ToList();
        this.gvDtypes.DataSource = dTypes;
        this.gvDtypes.DataBind();
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        DocumentType docType = new DocumentType();
        docType.Type_Name = txtJobName.Text;
        docType.File_Extension = txtExtension.Text;
        docType.Type_Desc = txtDescription.Text;
        docType.Office_Code = Author.office_Code;
        docType.Creation_Date = DateTime.Now;
        docType.Updation_Date = DateTime.Now;

        myDmsEntity.DocumentType.AddObject(docType);
        if (myDmsEntity.SaveChanges()>0)
        {
            lblMessage.Text = "Saved Successfully";
        }
        else
        {
            lblMessage.Text = "Error!";
        }
        lblMessage.Visible = true;
    }
}
